import socket

class Struct_Socket:
    address:str
    port:int
    max_player_number:int
    def __init__(self,address="127.0.0.1",
                 port=25565,
                 max_player_number=5
                 ) -> None:
        self.address=address
        self.port=port
        self.max_player_number=max_player_number
    
def  socket_init(struct_Socket:Struct_Socket) -> socket.socket:
    #tcp协议
    mysocket=socket.socket(type=socket.SOCK_STREAM)
    #绑定ip、端口
    mysocket.bind((struct_Socket.address,struct_Socket.port))
    # 监听客户端的连接请求
    mysocket.listen(struct_Socket.max_player_number)

    mysocket.settimeout(1)

    return mysocket
        
